cmake_minimum_required(VERSION 3.4.1)

project(cworker)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)

set(THIRD_LIB_HIREDIS ${CMAKE_CURRENT_SOURCE_DIR}/third/hiredis-v0.14.0)

include_directories(
    ${THIRD_LIB_HIREDIS}
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_SOURCE_DIR}/src
)

link_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/lib
)

file(GLOB_RECURSE CWORKER_SRC_LIST "src/*c")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -fmessage-length=0")
#set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -Wl,-rpath=./lib")

add_subdirectory(${THIRD_LIB_HIREDIS})

add_executable(${PROJECT_NAME} ${CWORKER_SRC_LIST})
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)
target_link_libraries(${PROJECT_NAME} curl hiredis pthread m)
